import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/views/layout/Layout'

/* Router Modules */
import componentsRouter from './modules/components'
import chartsRouter from './modules/charts'
import tableRouter from './modules/table'
import nestedRouter from './modules/nested'

/** note: Submenu only appear when children.length>=1
 *  detail see  https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
 **/

/**
* hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
* alwaysShow: true               if set true, will always show the root menu, whatever its child routes length
*                                if not set alwaysShow, only more than one route under the children
*                                it will becomes nested mode, otherwise not show the root menu
* redirect: noredirect           if `redirect:noredirect` will no redirect in the breadcrumb
* name:'router-name'             the name is used by <keep-alive> (must set!!!)
* meta : {
    roles: ['admin','editor']    will control the page roles (you can set multiple roles)
    title: 'title'               the name show in submenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar
    noCache: true                if true, the page will no be cached(default is false)
    breadcrumb: false            if false, the item will hidden in breadcrumb(default is true)
  }
**/

export const constantRouterMap = [

  {
    path: '/redirect',
    component: Layout,
    hidden: true,
    children: [{
      path: '/redirect/:path*',
      component: () =>
        import('@/views/redirect/index')
    }]
  },
  {
    path: '/login',
    component: () =>
      import('@/views/login/index'),
    hidden: true
  },
  {
    path: '/auth-redirect',
    component: () =>
      import('@/views/login/authredirect'),
    hidden: true
  },
  {
    path: '/404',
    component: () =>
      import('@/views/errorPage/404'),
    hidden: true
  },
  {
    path: '/401',
    component: () =>
      import('@/views/errorPage/401'),
    hidden: true
  },

  {
    path: '',
    component: Layout,
    hidden:true,
    redirect: 'dashboard',
    name: 'Dashboard',
    children: [{
      path: 'dashboard',
      component: () =>
        import('@/views/Outofstock/Report'),
      name: 'index',
      meta: {
        title: 'dashboard',
        icon: 'dashboard',
        noCache: true
      }
    }]
  }
]

export default new Router({
  //	 mode: 'history', 
  // require service support
  scrollBehavior: () => ({
    y: 0
  }),
  routes: constantRouterMap
})

export const asyncRouterMap = [
  // {
  //   "path": "external-link",
  //   "component": Layout,
  //   "children": [{
  //     "path": "https://sugar.baidubce.com/dashboard/c82ccfebb0f78adc97c662d3fd452043",
  //     "meta": {
  //       "title": "大数据",
  //       "icon": "link"
  //     }
  //   }]
  // },

  {
    path: '/Outofstock',
    component: Layout,
    redirect: '/Outofstock/Delivery',
    name: 'Outofstock',
    meta: {
      title: '采购报表',
      icon: 'oder'
    },
    children: [
      // {
      //   path: 'Maintain',
      //   name: 'Maintain',
      //   component: () => import('@/views/Outofstock/Maintain'),
      //   meta: {
      //     title: '采购系数',
      //     icon: 'oder'
      //   }
      // },

      {
        path: 'Report',
        name: 'Report',
        component: () => import('@/views/Outofstock/Report'),
        meta: {
          title: '补货建议',
          icon: 'oder'
        }
      },

      {
        path: 'cc',
        name: 'cc',
        component: () => import('@/views/Outofstock/cc'),
        meta: {
          title: '供应商汇总',
          icon: 'oder'
        }
      },

      {
        path: 'xx',
        name: 'xx',
        component: () => import('@/views/Outofstock/xx'),
        meta: {
          title: '商品汇总',
          icon: 'oder'
        }
      },

      {
        path: 'zz',
        name: 'zz',
        component: () => import('@/views/Outofstock/zz'),
        meta: {
          title: '采购明细表',
          icon: 'oder'
        }
      },
    ]
  },

  {
    path: '/Purchase',
    component: Layout,
    redirect: '/Purchase/Purchase',
    name: 'Purchase',
    meta: {
      title: '采购单',
      icon: 'oder'
    },
    children: [{
        path: 'Purchase',
        name: 'Purchase',
        component: () => import('@/views/Purchase/Purchase'),
        meta: {
          title: '采购列表',
          icon: 'oder'
        }
      },

      {
        path: 'Orders',
        name: 'Orders',
        component: () => import('@/views/Purchase/Orders'),
        meta: {
          title: '采购订单',
          icon: 'oder'
        }
      },
    ]
  },

  {
    path: '/Inspection',
    alwaysShow:true,
    component: Layout,
    redirect: '/Inspection/Inspection',
    name: 'Inspection',
    meta: {
      title: '验货入库',
      icon: 'oder'
    },
    children: [{
        path: 'Inspectionlist',
        name: 'Inspectionlist',
        component: () => import('@/views/Inspection/Inspectionlist'),
        meta: {
          title: '验货入库单',
          icon: 'oder'
        }
      },

      {
        hidden:true,
        path: 'Inspection',
        name: 'Inspection',
        component: () => import('@/views/Inspection/Inspection'),
        meta: {
          title: '验货入库单',
          icon: 'oder'
        }
      },

      // {
      //   path: 'Inspectioning',
      //   name: 'Inspectioning',
      //   component: () => import('@/views/Inspection/Inspectioning'),
      //   meta: {
      //     title: '验货入库单选择',
      //     icon: 'oder'
      //   }
      // },
    ]
  },

  // {
  //   path: '/procurement',
  //   component: Layout,
  //   redirect: '/procurement/proposal',
  //   name: 'proposal',
  //   meta: {
  //     title: '补货',
  //     icon: 'oder'
  //   },
  //   children: [{
  //       path: 'proposal',
  //       name: 'proposal',
  //       component: () => import('@/views/procurement/proposal'),
  //       meta: {
  //         title: '补货建议',
  //         icon: 'oder'
  //       }
  //     },
  //   ]
  // },

  // {
  //   path: '/Procurementfrom',
  //   component: Layout,
  //   redirect: '/Procurementfrom/Detailed',
  //   name: 'Procurementfrom',
  //   meta: {
  //     title: '采购',
  //     icon: 'oder'
  //   },
  //   children: [{
  //       path: 'Procurementfrom',
  //       name: 'Procurementfrom',
  //       component: () => import('@/views/Procurementfrom/Detailed'),
  //       meta: {
  //         title: '采购明细',
  //         icon: 'oder'
  //       }
  //     },

  //     {
  //       path: '',
  //       name: 'Summary',
  //       component: () => import('@/views/Procurementfrom/Summary'),
  //       meta: {
  //         title: '采购商品汇总',
  //         icon: 'Summary'
  //       }
  //     },
  //     {
  //       path: 'Supplier',
  //       name: 'Supplier',
  //       component: () => import('@/views/Procurementfrom/Supplier'),
  //       meta: {
  //         title: '采购供应商汇总',
  //         icon: 'Summary'
  //       }
  //     },
  //   ]
  // },
  // {
  //   path: '/payment',
  //   component: Layout,
  //   redirect: '/payment/payment',
  //   name: 'proposal',
  //   meta: {
  //     title: '付款单',
  //     icon: 'oder'
  //   },
  //   children: [{
  //       path: 'payment',
  //       name: 'payment',
  //       component: () => import('@/views/payment/payment'),
  //       meta: {
  //         title: '付款单',
  //         icon: 'oder'
  //       }
  //     },
  //   ]
  // },

  // {
  //   path: '/shop',
  //   component: Layout,
  //   redirect: '/shop/shop',
  //   name: 'shop',
  //   meta: {
  //     title: '门店',
  //     icon: 'shop'
  //   },
  //   children: [{
  //       path: 'shop',
  //       name: 'shop',
  //       component: () => import('@/views/shop/shop'),
  //       meta: {
  //         title: '门店',
  //         icon: 'oder'
  //       }
  //     },
  //     {
  //       hidden: true,
  //       path: 'performance',
  //       name: 'performance',
  //       component: () => import('@/views/shop/performance'),
  //       meta: {
  //         title: '门店销售记录',
  //         icon: 'oder'
  //       }
  //     },
  //   ]
  // },

  // {
  //   path: '/Class',
  //   component: Layout,
  //   redirect: '/Class/SKU',
  //   name: 'Class',
  //   meta: {
  //     title: '商品管理',
  //     icon: 'shop'
  //   },
  //   children: [{
  //     path: 'SKU',
  //     name: 'SKU',
  //     component: () => import('@/views/Class/SKU'),
  //     meta: {
  //       title: '商品管理',
  //       icon: 'oder'
  //     }
  //   }, {
  //     hidden: true,
  //     path: 'certificate',
  //     name: 'certificate',
  //     component: () => import('@/views/Class/certificate'),
  //     meta: {
  //       title: '查看证书',
  //       icon: 'oder'
  //     }
  //   }, ]
  // },

  // {
  //   path: '/Oder',
  //   component: Layout,
  //   redirect: '/Oder/Oderall',
  //   name: 'oder',
  //   meta: {
  //     title: '订货',
  //     icon: 'oder'
  //   },
  //   children: [{
  //       path: 'oderlist',
  //       name: 'oderlist',
  //       component: () => import('@/views/Oder/oderlist'),
  //       meta: {
  //         title: '订货',
  //         icon: 'oder'
  //       }
  //     },
  //     {
  //       path: 'Oderall',
  //       name: 'Oderall',
  //       component: () => import('@/views/Oder/Oderall'),
  //       meta: {
  //         title: '向供货商订货',
  //         icon: 'oder'
  //       }
  //     },
  //     {
  //       path: 'list',
  //       name: 'purchaseoderhistorylist',
  //       component: () => import('@/views/Oder/list'),
  //       meta: {
  //         title: '历史列表',
  //         icon: 'oderlist'
  //       }
  //     }
  //   ]
  // },

  {
    path: '/return',
    component: Layout,
    redirect: '/ return/list',
    name: 'returns',
    meta: {
      title: '退货出库单',
      icon: 'returnlist'
    },
    children: [{
        path: 'approval',
        name: 'returnlistapproval',
        component: () => import('@/views/return/approval'),
        meta: {
          title: '退货出库单列表',
          icon: 'approval'
        }
      },

      {
        path: 'returnlist',
        name: 'returnlists',
        component: () => import('@/views/return/returnlist'),
        meta: {
          title: '退货出库单',
          icon: 'list'
        }
      }
    ]
  },

  //修改密码
  {
    hidden: true,
    path: '/password',
    component: Layout,
    redirect: '/password/password',
    name: 'data',
    meta: {
      title: '登录密码',
      icon: 'data'
    },
    children: [{
      path: 'password',
      name: 'bossdata',
      component: () =>
        import('@/views/password/password'),
      meta: {
        title: '登录密码',
        icon: 'data'
      }
    }]
  },

  // {
  //   path: '/Receiving',
  //   component: Layout,
  //   redirect: '/Receiving/receiving',
  //   name: 'receiving',
  //   meta: {
  //     title: '收货',
  //     icon: 'receiving'
  //   },
  //   children: [{
  //       path: 'receiving',
  //       component: () =>
  //         import('@/views/Receiving/receiving'),
  //       name: 'purchasereceiving',
  //       meta: {
  //         title: '收货',
  //         icon: 'receiving'
  //       }
  //     },
  //     {
  //       path: 'historylist',
  //       component: () =>
  //         import('@/views/Receiving/historylist'),
  //       name: 'purchasereceivinghistorylist',
  //       meta: {
  //         title: '历史列表',
  //         icon: 'oderlist'
  //       }
  //     },
  //   ]
  // },
  // {
  //   path: '/abnormal',
  //   component: Layout,
  //   redirect: '/abnormal/abnormal',
  //   name: 'abnormal',
  //   meta: {
  //     title: '异常单',
  //     icon: 'abnormal'
  //   },
  //   children: [{
  //       path: 'abnormal',
  //       component: () =>
  //         import('@/views/abnormal/abnormal'),
  //       name: 'purchaseabnormal',
  //       meta: {
  //         title: '异常单',
  //         icon: 'abnormal'
  //       }
  //     },
  //     {
  //       path: 'historylist',
  //       component: () =>
  //         import('@/views/abnormal/historylist'),
  //       name: 'purchaseabnormalhistorylist',
  //       meta: {
  //         title: '历史列表',
  //         icon: 'oderlist'
  //       }
  //     },
  //   ]
  // },
  // {
  //   path: '/Deliver',
  //   component: Layout,
  //   redirect: '/Deliver/deliver',
  //   name: 'deliver',
  //   meta: {
  //     title: '发货',
  //     icon: 'deliver'
  //   },
  //   children: [{
  //       path: 'receiving',
  //       component: () =>
  //         import('@/views/Deliver/deliver'),
  //       name: 'purchasedeliver',
  //       meta: {
  //         title: '发货',
  //         icon: 'deliver'
  //       }
  //     },
  //     {
  //       path: 'historylist',
  //       component: () =>
  //         import('@/views/Deliver/historylist'),
  //       name: 'purchasedeliverhistorylist',
  //       meta: {
  //         title: '历史列表',
  //         icon: 'oderlist'
  //       }
  //     },
  //   ]
  // },
  // {
  //   path: '/Supplier',
  //   component: Layout,
  //   redirect: '/Supplier/supplierlist',
  //   name: 'supplier',
  //   meta: {
  //     title: '供货商管理',
  //     icon: 'supplier'
  //   },
  //   children: [{
  //     path: 'supplierlist',
  //     component: () =>
  //       import('@/views/Supplier/supplierlist'),
  //     name: 'slist',
  //     meta: {
  //       title: '供货商列表',
  //       icon: 'list'
  //     }
  //   }]
  // },

  // {
  // 		path: '/Balance',
  // 	component: Layout,
  // 	redirect: '/Balance/recharge',
  // 	name: 'recharge',
  // 	meta: {
  // 		title: '余额',
  // 		icon: 'money'
  // 	},
  // 	children: [{
  // 			path: 'recharge',
  // 			component: () =>
  // 				import('@/views/Balance/recharge'),
  // 			name: 'agentrecharge',
  // 			meta: {
  // 				title: '充值记录',
  // 				icon: 'recharge'
  // 			}
  // 		},
  // 		{
  // 			path: 'consume',
  // 			component: () =>
  // 				import('@/views/Balance/consume'),
  // 			name: 'agentconsume',
  // 			meta: {
  // 				title: '消费记录',
  // 				icon: 'consume'
  // 			}
  // 		}
  // 	]
  // },
  /** When your routing table is too long, you can split it into small modules**/
  // componentsRouter,
  // chartsRouter,
  // nestedRouter,
  // tableRouter,
  // {
  //     path: '/Auditing',
  //     component: Layout,
  //     redirect: '/Auditing/oder',
  //     name: 'Auditing',
  //     meta: { title: '审核', icon: 'oder' },
  //     children: [
  //     {
  //      path: 'oder',
  //      name: 'bossoder',
  //      component: () => import('@/views/Auditing/oder'),
  //      meta: { title: '订货审核', icon: 'oder' }
  //    } ,
  //    {
  //      path: 'money',
  //      name: 'bossmoney',
  //      component: () => import('@/views/Auditing/money'),
  //      meta: { title: '打款审核', icon: 'money' }
  //    }    
  //     ]
  //   },

  // {
  //     path: '/journaling',
  //     component: Layout,
  //     redirect: '/ journaling/journaling',
  //     name: 'journaling',
  //     meta: { title: '报表', icon: 'journaling' },
  //     children: [
  //     {
  //      path: 'journaling',
  //      name: 'bossjournaling',
  //      component: () => import('@/views/journaling/journaling'),
  //      meta: { title: '报表', icon: 'journaling' }
  //    } 
  //     ]
  //   },
  //   {
  //     path: '/configure',
  //     component: Layout,
  //     redirect: '/ configure/configure',
  //     name: 'configure',
  //     meta: { title: '配置', icon: 'configure' },
  //     children: [

  //     {
  //      path: 'configure',
  //      name: 'bossconfigure',
  //      component: () => import('@/views/configure/configure'),
  //      meta: { title: '配置', icon: 'configure' }
  //    } 
  //     ]
  //   },

  {
    path: '*',
    redirect: '/404',
    hidden: true
  }
]
